/**
 * 
 */
package de.nordakademie.wpk.boerse.ui.provider;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import de.nordakademie.wpk.boerse.core.data.Depot;
import de.nordakademie.wpk.boerse.core.data.Stock;

/**
 * @author Marcus Berndt
 */
public class StockLabelProvider extends LabelProvider implements
		ITableLabelProvider {

	/**
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object,
	 *      int)
	 */
	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		return null;
	}

	/**
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
	 *      int)
	 */
	@Override
	public String getColumnText(Object element, int columnIndex) {
		Stock stock = (Stock) element;
		switch (columnIndex) {
		case 0:
			return stock.getName();
		case 1:
			return stock.getLast().toString();
		case 2:
			return stock.getSymbol();
		case 3:
			return stock.getWkn();
		case 4:
			return stock.getCurrency().toString();
		case 5:
			final Depot depot = stock.getDepot();
			if (depot == null)
				return "1";
			return depot.getAmountOfStock(stock).toString();
		}
		return "";
	}

}
